package com.guiguli.MathDemo2;

public class MathDemo2 {
    public static void main(String[] args) {
        //判断一个数是否为质数
        System.out.println(isPrime(997));
        System.out.println(Math.sqrt(26));
        //997 2-996 955次

        //优化后只需30次
    }

    public static boolean isPrime(int number) {
        int count = 0;
        for (int i = 2; i <= Math.sqrt(number); i++) {
            count++;
            if (number % i == 0)
                return false;
        }
        System.out.println(count);
        return true;
    }
    public static boolean isPrime2(int number) {
        for (int i = 2; i < number; i++) {
            if (number % i == 0)
                return false;
        }
        return true;
    }
}
